#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/rculist.h>
#include <asm-generic/errno-base.h>
#include <uapi/asm-generic/errno.h>

static LIST_HEAD(my_list);

struct struct1 {
	struct list_head list;
	char name[20];
};

void inline stack01(void) {
	struct struct1 a0 = { .name = "a4", };
	struct struct1 a1 = { .name = "a5", };
	struct struct1 a2 = { .name = "a6", };
	struct struct1 a3 = { .name = "a7", };
	struct struct1 *pos;
//	struct list_head;

	list_add_rcu(&a0.list, &my_list);
	list_add_rcu(&a1.list, &my_list);
	list_add_rcu(&a2.list, &my_list);
	list_add_rcu(&a3.list, &my_list);

	list_for_each_entry_rcu(pos, &my_list, list)
	{
		pr_err("name = %s\n", pos->name);
	}

	list_del_rcu(&a2.list);
	pr_err("after delete\n");

	list_for_each_entry_rcu(pos, &my_list, list)
	{
		pr_err("name = %s\n", pos->name);
	}

}

int myinit(void) {
	stack01();
	return 0;
}

static __init int my_init(void) {
	return  myinit();
}

static void __exit my_exit(void) {

}

module_init(my_init);
module_exit(my_exit);

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Andy");
MODULE_DESCRIPTION("A sample c  driver");
